const makePage = (total, cur, around) => {
    let result = [];
    let baseCount = around * 2 + 1 + 2 + 2 + 2;
    let surplus = baseCount - 4;
    let startPosition = 1 + 2 + around + 1;
    let endPosition = total - 2 - around -1;

    if(total <= baseCount - 2){
        result = [...Array.from({length: total}, (v, i) => i + 1)]
    }else {
        if(cur < startPosition){
            result = [...Array.from({length: surplus}, (v, i) => i + 1), "...", total]
        }else if(cur > endPosition){
            result = [1, '...', ...Array.from({length: surplus}, (v, i) => total - surplus + i + 1)]
        }else {
            result = [1, '...', ...Array.from({length: around * 2 + 1}, (v, i) => cur - around + i), "...", total]
        }
    }
    return result;
}
makePage(7,2,2);
makePage(20,3,2);
makePage(20,10,2);
makePage(20,19,2);